<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>配送运费支付管理</title>
    <link rel="stylesheet" href="../../layui-v2.6.8/layui/css/layui.css">
    <script type="text/javascript" src="../../layui-v2.6.8/layui/layui.js"></script>
</head>
<body>
<table id="demo" lay-filter="test"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-container layui-btn-xs" lay-event="query">查看所有订单</a>
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="pay">合计总金额</a>
</script>
<script>
    layui.use(['table','layer'], function(){
        var table = layui.table;
        var $ = layui.$;
        var layer = layui.layer;

        table.render({
            elem: '#demo'
            ,url: 'http://localhost:8080/all'
            ,page: true
            ,cols: [[
                 {field: 'cid', title: '客户编号'}
                , {field: 'cname', title: '客户名称'}
                , {field: 'cphone', title: '客户联系方式'}
                , {fixed: 'right', title: '操作', toolbar: '#barDemo'}
            ]]
        });
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            // 查询
            if (obj.event === 'query') {
                layer.open({
                    type: 1,
                    skin: 'layui-layer-molv',
                    area: 'auto',
                    title: ['订单信息', 'font-size:18px'],
                    shadeClose: true,
                    maxmin: true,
                    content: $('#query')
                });
                table.render({
                    elem: '#check'
                    ,url: 'http://localhost:8080/queryByCid?cid='+data.cid
                    ,page: true
                    ,cols: [[
                        , {field: 'acontact', title: '寄件人'}
                        , {field: 'aphone', title: '寄件人电话'}
                        , {field: 'address', title: '寄件人地址'}
                        , {field: 'acontact2', title: '收件人'}
                        , {field: 'aphone2', title: '收件人电话'}
                        , {field: 'address2', title: '收件人地址'}
                        , {field: 'kind', title: '货物类别'}
                        , {field: 'unitprice', title: '单价'}
                        , {field: 'pweight', title: '重量'}
                        , {field: 'psum', title: '运费'}
                        , {field: 'otime', title: '下单时间'}
                        , {field: 'tip', title: '留言'}
                    ]]
                });
            } else if (obj.event === 'pay') {
                //支付
                layer.open({
                    type: 1,
                    skin: 'layui-layer-molv',
                    area: 'auto',
                    title: ['合计总金额', 'font-size:18px'],
                    shadeClose: true,
                    content: $('#pay')
                });
                table.render({
                    elem: '#zfb'
                    ,url: 'http://localhost:8080/sumByCid?cid='+data.cid
                    ,cols: [[
                        {field: 'psum', title: '合计总金额'}
                    ]]
                });
            }
        });
    });
</script>
</body>
<div class="layui-row" id="query" style="display:none;">
    <table id="check" lay-filter="check"></table>
</div>
<div class="layui-row" id="pay" style="display:none;">
    <table id="zfb" lay-filter="zfb"></table>
</div>
</html>